#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>

int main(){

	int fd;
	char *buf = "zzxl 666!";

	fd = open ("./file1",O_RDWR);
	
	if(fd == -1){
		
		printf("open file1 failed!\n");
	}
	
	fd=open("./file1",O_RDWR|O_CREAT,0600);
	
	if(fd > 0){
		printf("creat file1 success\n");
	}
	printf("open success : fd=%d\n",fd);
	
	//ssize_t write(int fd, const void *buf, size_t count);
	write(fd,buf,strlen(buf));
	//int close(int fd);
	close(fd);

	return 0;
}
